feat(schema): createdAt/updatedAt on every domain entity (P4-K)#84
Merged
Conversation
Architect audit P4-K. Add `createdAt`/`updatedAt` TIMESTAMPTZ columns
to 18 tables and flip every model from `timestamps: false` to
`timestamps: true` so Sequelize auto-populates them on every write.
Why
- Auditability: every row carries creation + last-modification time
without each controller maintaining it by hand.
- Sync clients: third-party integrations get a reliable "what's
changed since T" boundary for delta-pull workflows.
- Observability: ad-hoc analytics on "new customers per day", etc.,
trivially work off `createdAt` rather than a row counter.
Coverage
- 18 tables touched: ApiKey, ApiMaster, BillingType, Company,
Customer, CustomerPayment, InventoryItem, InventoryTransactions,
Invoice, InvoiceJob, Job, ProductEntry, PurchaseOrderHeaders,
PurchaseOrderLines, PurchaseOrderVendors, TimeEntry, VersionInfo,
Worker.
- IdempotencyKey is INTENTIONALLY excluded — it already manages its
own `ikCreatedAt` / `ikExpiresAt` pair and a parallel
createdAt/updatedAt would be redundant and confusing.
Backfill
- Existing rows have no recorded history; the migration backfills
both columns to `now()` via the column DEFAULT. Operators carrying
legacy Atbash SQL Server timestamps can patch real values
post-migration via a one-off UPDATE.
Down migration
- Drops the two columns from every table. No FKs reference them,
so the rollback is straight-forward.
Tests
- New `tests/unit/timestamps.test.js` (36 cases) — every model
asserts `options.timestamps === true` AND
`rawAttributes.{createdAt,updatedAt}` exist.
- Full suite: 401 pass / 4 skip (was 365/4).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of architect audit issue #73 — iteration P4-K.
Summary
createdAt/updatedAtTIMESTAMPTZ columns to 18 tables.timestamps: false→trueso Sequelize maintains the columns automatically.now()via column default; operators carrying legacy Atbash SQL Server timestamps can patch real values post-migration.Test plan
tests/unit/timestamps.test.js(36 cases): every model hastimestamps:true+createdAt/updatedAtattrs.This code proudly made in Nebraska. GO BIG RED! 🌽 https://xkcd.com/2347/